﻿<!DOCTYPE html>
<html>
<head>
    <script src="/js/header.js"></script>
    <script src="/lib/date/wdatepicker.js"></script>
    <link href="/lib/select2/select2.min.css" rel="stylesheet" />
    <script src="/lib/select2/select2.min.js"></script>
</head>
<body style="background-color: white;">
    <section class="container-fluid" style="background-color: white;">

        <ul class="nav nav-tabs m15_t" id="myTab">
            <li class="active"><a href="#home" data-toggle="tab">银行卡基本信息</a></li>
            <li class="limit"><a href="#ext" data-toggle="tab">额外限制</a></li>
            <li class="transportCard"><a href="#transportCard" data-toggle="tab">中转设定</a></li>
        </ul>

        <form class="form-horizontal m15_t" id="form" onsubmit="return false;">
            <div class="row m15_t" id="header">
                <a href="#head"></a>

                <div class="tab-content col-md-3">

                    <input type="hidden" name="bcid" value="0">

                    <div class="tab-pane fade in active" id="home">
                        <div class="form-group">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>银行卡类型：</label>
                            <select class="input-group wd250" name="cardType">
                                <option value="1">收款卡</option>
                                <option value="2">中转卡</option>
                                <option value="3">付款卡</option>
                                <option value="4">备用卡</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">公司名称：</label>
                            <select class="input-group wd250" name="companyId">
                                <option value="0">未分配</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">银行名称：</label>
                            <select class="input-group wd250" name="bankCode" disabled></select>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>订单号：</label>
                            <div class="">
                                &nbsp;&nbsp;&nbsp; <label class="wd125 control-label" style="margin-top:7px;font-weight:bold;" id="orderNo"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>银行卡号：</label>
                            <div class="">
                                &nbsp;&nbsp;&nbsp; <label class="wd125 control-label" style="margin-top:7px;font-weight:bold;" id="cardNumber"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">银行副卡号：</label>
                            <div class="">
                                &nbsp;&nbsp;&nbsp; <label class="wd125 control-label" style="margin-top:7px;font-weight:bold;" id="secCardNumber"></label>
                            </div>
                        </div>
                        <!--中转卡号开始-->
                        <!--<div class="form-group apiTransport">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>使用接口生成中转订单：</label>
                            <div class="">
                                <select class="input-group wd250" name="apiTransport">
                                    <option value="">请选择</option>
                                    <option value="1">启用</option>
                                    <option value="2">禁用</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group limitAmount">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>触发中转金额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitAmount" maxlength="10" value="0" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group limitTransFerAmount">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>每次中转金额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitTransFerAmount" maxlength="10" value="0" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group limitBalance">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>预留账户金额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitBalance" maxlength="10" value="0" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group limitMaxAmount">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>转账最大额度：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitMaxAmount" maxlength="10" value="0" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group limitCardType">
                            <label class="wd125 control-label">转入卡类别：</label>
                            <select class="input-group wd250" name="limitCardType">
                                <option value="">请选择</option>
                                <option value="1">收款卡</option>
                                <option value="2">中转卡</option>
                                <option value="3">付款卡</option>
                                <option value="5">储备</option>
                                <option value="6">下发储备</option>
                                <option value="7">付款储备</option>
                            </select>
                        </div>
                        <div class="form-group limitOrderSideBalance">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>转入卡余额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitOrderSideBalance" maxlength="10" value="0" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group limitBankCode">
                            <label class="wd125 control-label">转入卡银行：</label>
                            <div class="">
                                <select class="input-group wd250" name="limitBankCode"></select>
                            </div>
                        </div>-->
                        <!--中转卡号结束-->
                        <div class="form-group">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>银行卡使用状态：</label>
                            <select class="input-group wd250" name="usingStatus" id="usingStatus">
                                <option value="">请选择</option>
                                <option value="1">有效</option>
                                <option value="2">冻结</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>银行卡启用状态：</label>
                            <select class="input-group wd250" name="enableStatus">
                                <option value="">请选择</option>
                                <option value="1">启用</option>
                                <option value="2">禁用</option>
                            </select>
                        </div>
                        <div class="side" style="border:0px solid #a09a9a;">
                            <div class="form-group">
                                <label class="wd125 control-label">登陆名称：</label>
                                <div class="input-group wd250">
                                    <div id="loginName" style="margin-top:8px;"></div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="wd125 control-label">登陆密码：</label>
                                <div class="input-group wd250">
                                    <input class="form-control" type="password" id="passwordLogin" name="passwordLogin" readonly maxlength="40" autocomplete="off" disabled>
                                    <span class="input-group-addon" onclick="changeInputType(this);">
                                        <i class="glyphicon glyphicon-eye-close"></i>
                                    </span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="wd125 control-label">查询密码：</label>
                                <div class="input-group wd250">
                                    <input class="form-control" type="password" name="passwordQuery" maxlength="40" placeholder="长度必须介于 6 和 40 之间" autocomplete="off">
                                    <span class="input-group-addon" onclick="changeInputType(this);"><i class="glyphicon glyphicon-eye-close"></i></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="wd125 control-label"><span class="WdateFmtErr">*</span>支付密码：</label>
                                <div class="input-group wd250">
                                    <input class="form-control" type="password" name="passwordPay" readonly maxlength="40" autocomplete="off" disabled>
                                    <span class="input-group-addon" onclick="changeInputType(this);"><i class="glyphicon glyphicon-eye-close"></i></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="wd125 control-label">网盾密码：</label>
                                <div class="input-group wd250">
                                    <input class="form-control" type="password" name="passwordShield" readonly" maxlength="40" autocomplete="off" disabled>
                                    <span class="input-group-addon" onclick="changeInputType(this);"><i class="glyphicon glyphicon-eye-close"></i></span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">原始密码：</label>
                            <div class="input-group wd250">
                                <input class="form-control" type="password" name="originalPassword" readonly maxlength="40" autocomplete="off" disabled>
                                <span class="input-group-addon" onclick="changeInputType(this);">
                                    <i class="glyphicon glyphicon-eye-close"></i>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>网盾类型：</label>
                            <select class="" name="usbType" id="usbType">
                                <option value="1">手工</option>
                                <option value="2">自动</option>
                            </select>
                        </div>
                        <div class="form-group paymentStart" id="divPaymentStart">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>付款区间起：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="paymentStart" maxlength="16" value="0" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group paymentEnd" id="divPaymentEnd">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>付款区间迄：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="paymentEnd" maxlength="16" value="0" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group payFeeRatio" id="divPayFeeRatio">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>付款费率(%)：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="payFeeRatio" maxlength="10" value="0" autocomplete="off">
                            </div>
                            <div class="" style="margin-left:63px">
                                <span>PS:如填写"0", 报表计算则依照公司设定公共费率计算</span>
                            </div>
                        </div>
                        <!--中转卡(中转费率)-->
                        <div class="form-group transportRate">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>中转费率(%)：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="transportRate" maxlength="10" value="0" autocomplete="off">
                            </div>
                            <div class="" style="margin-left:63px">
                                <span>PS:如填写"0", 报表计算则依照公司设定公共费率计算</span>
                            </div>
                        </div>
                        <div class="form-group crossBankPay" id="divCrossBankPay">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>跨行转账：</label>
                            <select class="" name="crossBankPay">
                                <option value="1">同行</option>
                                <option value="2">跨行</option>
                                <option value="3">全部</option>
                            </select>
                        </div>
                        <div class="form-group paymentType" id="divPaymentType">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>付款类型：</label>
                            <select class="" name="paymentType"></select>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">开户地：</label>
                            <div class="">
                                &nbsp;&nbsp;&nbsp; <label class="wd125 control-label" style="margin-top:7px;" id="accountBank"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">证件号码：</label>
                            <div class="input-group wd250">
                                &nbsp;&nbsp;&nbsp; <label class="wd125 control-label" style="margin-top:7px;" id="documentNumber"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">手机号码：</label>
                            <div class="input-group wd250">
                                &nbsp;&nbsp;&nbsp; <label class="wd125 control-label" style="margin-top:7px;" id="phoneNumber"></label>
                            </div>
                        </div>
                        <div class="form-group depositType">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>存款等级：</label>
                            <div class="input-group wd250">
                                <input type="checkbox" name="deposit" value="A" />1x
                                <input type="checkbox" name="deposit" value="B" />2x
                                <input type="checkbox" name="deposit" value="C" />3x
                                <input type="checkbox" name="deposit" value="D" />4x
                                <input type="checkbox" name="deposit" value="E" />5x
                                <input type="checkbox" name="deposit" value="F" />6x
                                <input type="checkbox" name="deposit" value="G" />7x
                                <input type="checkbox" name="deposit" value="H" />8x
                                <input type="checkbox" name="deposit" value="I" />9x
                                <input type="checkbox" name="deposit" value="J" />10x
                                <input type="checkbox" name="deposit" value="K" />11x
                                <input type="checkbox" name="deposit" value="L" />12x
                                <input type="checkbox" name="deposit" value="X" />x
                            </div>
                        </div>
                        <div class="form-group depositFeeRatio" id="divDepositFeeRatio">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>收款费率(%)：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="depositFeeRatio" maxlength="10" value="0" autocomplete="off">
                            </div>
                            <div class="" style="margin-left:63px">
                                <span>PS:如填写"0", 报表计算则依照公司设定公共费率计算</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">机器位置：</label>
                            <div class="">
                                &nbsp;&nbsp;&nbsp; <label class="wd125 control-label" style="margin-top:7px;" id="ipAddress"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">支付宝卡编号：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="aliPayCardIndex" maxlength="30" placeholder="长度必须介于  0 或 30" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">支付宝银行编码：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="aliPayBankMark" maxlength="30" placeholder="长度必须介于  0 或 30" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">支付宝姓名：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="aliPayCardName" maxlength="20" placeholder="长度必须介于  0 或 20" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="wd125 control-label">备注：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="remark" maxlength="50" autocomplete="off">
                            </div>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="ext">
                        <!--<div class="form-group">
        <label class="wd125 control-label">关闭时间：</label>
        <div class="">
            <input class="form-control wd250 Wdate" type="text" name="limitCloseDate" maxlength="16" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'%y-%M-%d'})">
        </div>
    </div>
    <div class="form-group">
        <label class="wd125 control-label">开启时间：</label>
        <div class="">
            <input class="form-control wd250 Wdate" type="text" name="limitOpenDate" maxlength="16" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'d421\')}'})">
        </div>
    </div>
    <div class="form-group">
        <label class="wd125 control-label"><span class="WdateFmtErr">*</span>每天执行：</label>
        <div class="wd250 m15_l">
            <label class="m10_r">
                <input type="radio" name="limitRepeat" value="1"> 启用
            </label>
            <label>
                <input type="radio" name="limitRepeat" value="2"> 禁用
            </label>
        </div>
    </div>-->
                        <div class="form-group limitDepositAmount">
                            <label class="wd125 control-label">限制收款金额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitDepositAmount" placeholder="不限制，请配置 0 " maxlength="16" autocomplete="off" value="0">
                            </div>
                        </div>
                        <div class="form-group limitDepositCount">
                            <label class="wd125 control-label">限制收款笔数：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitDepositCount" placeholder="不限制，请配置 0 " maxlength="16" autocomplete="off" value="0">
                            </div>
                        </div>
                        <!--<div class="form-group">
        <label class="wd125 control-label"><span class="WdateFmtErr">*</span>转付款：</label>
        <div class="wd250 m15_l">
            <label class="m10_r">
                <input type="radio" name="limitChangetoPay" value="1"> 启用
            </label>
            <label>
                <input type="radio" name="limitChangetoPay" value="2"> 禁用
            </label>
        </div>
    </div>-->
                        <div class="form-group limitPayAmount">
                            <label class="wd125 control-label">限制付款金额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitPayAmount" placeholder="不限制，请配置 0 " maxlength="16" autocomplete="off" value="0">
                            </div>
                        </div>
                        <div class="form-group limitPayCount">
                            <label class="wd125 control-label">限制付款笔数：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="limitPayCount" placeholder="不限制，请配置 0 " maxlength="16" autocomplete="off" value="0">
                            </div>
                        </div>
                        <!--<div class="form-group">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>转收款：</label>
                            <div class="wd250 m15_l">
                                <label class="m10_r">
                                    <input type="radio" name="limitChangetoDeposit" value="1"> 启用
                                </label>
                                <label>
                                    <input type="radio" name="limitChangetoDeposit" value="2"> 禁用
                                </label>
                            </div>
                        </div>-->
                        <div class="form-group limitStatus">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>状态：</label>
                            <div class="wd250 m15_l">
                                <label class="m10_r">
                                    <input type="radio" name="limitStatus" value="1"> 启用
                                </label>
                                <label>
                                    <input type="radio" name="limitStatus" value="2"> 禁用
                                </label>
                            </div>
                        </div>
                        <div class="form-group limitPayCount">
                            <label class="wd125 control-label"></label>
                            <div class="">
                            </div>
                        </div>
                        <div class="form-group limitPayCount">
                            <label class="wd125 control-label"></label>
                            <div class="">
                            </div>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="transportCard">
                        <div class="form-group transferMethod">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>是否显示存款卡中：</label>
                            <div class="wd250 m15_l">
                                <label class="m10_r">
                                    <input type="radio" name="showedOnDepositCard" value="1"> 呈现
                                </label>
                                <label class="m5_t">
                                    <input type="radio" name="showedOnDepositCard" value="2"> 不呈现
                                </label>
                            </div>
                        </div>
                        <div class="form-group triggeredAmount">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>触发中转金额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="triggeredAmount" placeholder="触发中转金额，默认5000 " maxlength="10" autocomplete="off" value="0">
                            </div>
                        </div>
                        <div class="form-group transferredAmount">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>每次中转金额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="transferredAmount" placeholder="每次中转金额，不限制请配置 0 " maxlength="10" autocomplete="off" value="0">
                            </div>
                        </div>
                        <div class="form-group preservedBalance">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>预留账户金额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="preservedBalance" placeholder="预留账户金额，默认25 " maxlength="10" autocomplete="off" value="0">
                            </div>
                        </div>
                        <div class="form-group transferMethod">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>中转方式：</label>
                            <div class="wd250 m15_l">
                                <label class="m10_r">
                                    <input type="radio" name="transportMethod" value="1"> 自动
                                </label>
                                <label>
                                    <input type="radio" name="transportMethod" value="2"> 指定转入卡
                                </label>
                            </div>
                        </div>
                        <div class="form-group destinationBCID">
                            <div class="clearfix m50_l">
                                <div class="pull-left">
                                    <a class="btn btn-default" data-href="/view/bankcard/selectbank.html" data-title="选择银行" data-width="750" data-height="710" onclick="return service.selectbank(this);"><span class="glyphicon glyphicon-plus"></span> 选择</a>
                                </div>
                            </div>
                            <div class="data-view m50_l" style="overflow-x:hidden; width:80%">
                                <table class="table table-striped table-bordered transportCardRule">
                                    <thead>
                                        <tr>
                                            <th class="t_l wd120">转入卡</th>
                                            <th class="t_l wd100">限定金额</th>
                                            <th class="t_c wd50">操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group destinationOrderSideBalance">
                            <label class="wd125 control-label"><span class="WdateFmtErr">*</span>转入卡余额：</label>
                            <div class="">
                                <input class="form-control wd250" type="text" name="destinationOrderSideBalance" placeholder="转入卡余额，默认 30000" maxlength="10" autocomplete="off" value="0">
                            </div>
                        </div>
                        <div class="form-group destinationCardType">
                            <label class="wd125 control-label">转入卡类型：</label>
                            <div class="">
                                <select class="input-group wd250" name="destinationCardType" maxlength="40" autocomplete="off" multiple="multiple">
                                    <option value="">请选择</option>
                                    <option value="1">收款卡</option>
                                    <option value="2">中转卡</option>
                                    <option value="3">付款卡</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group destinationBankCode">
                            <label class="wd125 control-label">转入卡银行：</label>
                            <div class="">
                                <select class="input-group wd250" name="destinationBankCodes" maxlength="40" autocomplete="off" multiple="multiple"></select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group" style="margin-top:10px;padding: 10px 15px;border-top: 1px solid #e5e6e7;">
                <label class="wd100 control-label"></label>
                <div class="wd250 m15_l">
                    <button class="btn btn-primary m50_l" onclick="return save();">保存</button>
                    <button class="btn btn-default m10_l" onclick="return cancel();">取消</button>
                </div>
            </div>
        </form>
    </section>
    <script type="text/x-dot-template" id="addTpl">
        {{? it && it.length>0}}
        {{ for(var prop in it) { }}
        <tr>
            <td class="t_l wd120"><input class="form-control" type="hidden" name="destinationBCID" value="{{=it[prop]['id']}}">{{=it[prop]['description']}}</td>
            <td class="t_l wd100"><input class="form-control" type="text" name="destinationBCIDAmountLimit" value="{{=it[prop]['amountLimit']}}" maxlength="6" autocomplete="off" placeholder="限定金额"></td>
            <td class=" t_c wd50">
                <a class="btn btn-default btn-xs btn-danger" onclick="return service.delete(this)"><span class="glyphicon glyphicon-trash"></span>&nbsp;刪除</a>
            </td>
        </tr>
        {{ } }}
        {{??}}
        <tr class="noRecord">
            <td colspan="3">暂无记录！</td>
        </tr>
        {{?}}

    </script>
    <script type="text/javascript">

        var id = 0;
        var company = $("select[name='companyId']");
        var bank = $("select[name='bankCode']");
        var paymentType = $("select[name='paymentType']");
        //var destinationBankCode = $("select[name='destinationBankCode']");
        var destinationBankCodes = $("select[name='destinationBankCodes']");
        var destinationBCID = $("select[name='destinationBCID']");
        var destinationCardType = $("select[name='destinationCardType']");
        $(function () {

            id = FlashPay.Util.GetQueryString("id");

            init(id);

            $("select[name='cardType']").change(function () {
                var cardtype = $(this).find("option:selected").val()
                xx(cardtype);
            });

            $("input[name='transportMethod']").change(function () {
                var transferMethod = $(this).val()
                if (transferMethod == 1) {
                    $(".destinationBCID").hide();
                    $(".destinationCardType,.destinationBankCode,.destinationOrderSideBalance").show();
                } else {
                    $(".destinationBCID").show();
                    $(".destinationCardType,.destinationBankCode,.destinationOrderSideBalance").hide();
                }
            });

            destinationBCID.select2({ placeholder: '选择转入银行卡' });
            destinationCardType.select2({ placeholder: '选择转入卡类型' });
            destinationBankCodes.select2({ placeholder: '选择转入卡银行' });
        });

        var service = {
            getAddTpl: function () {
                return doT.template($("#addTpl").text());
            },
            insert: function() {

                var tpl = service.getAddTpl();

                $("table.table tbody").append(tpl(null));
            },
            selectbank: function (obj) {

                var modal = $(obj);
                var url = modal.data("href");
                url += "?" + Math.random();

                FlashPay.UI.DialogOpen(url, {
                    title: modal.data("title"),
                    width: modal.data("width"),
                    height: modal.data("height"),
                    init: function () {
                        this.button(
                            {
                                name: '关闭'
                            }
                        );
                    },
                });            },
            delete: function (obj) {
                $(obj).parent().parent().remove();
            },
            get: function () {

                var privileges = [];

                $("table.privileges > tbody > tr").each(function (index) {
                    var permissionId = $(this).find("input[name='permissionId']").val();
                    if (permissionId != null)
                        privileges.push(permissionId);
                });            }
        };

        function insertRow(obj) {

            var menuPermissionText = doT.template($("#addTpl").text());

            $("table.transportCardRule > tbody > tr.noRecord").remove();

            $("table.transportCardRule tbody").append(menuPermissionText(obj));
        }

        function init(id) {

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Bank/GetBank?bcId=" + id,
                dataType: "json",
                contentType: "application/json",
                success: function (res) {

                    xx(res.cardType);
                    if (res.companyResponse != null) {
                        $.each(res.companyResponse, function (i, item) {
                            company.append("<option value='" + item.companyID + "'>" + item.companyName + "</option >");
                        });
                    }
                    $("select[name='companyId']").find("option[value=" + res.companyId + "]").prop("selected", true);

                    if (res.bankInfoResponse != null) {
                        $.each(res.bankInfoResponse, function (i, item) {
                            bank.append("<option value='" + item.bankCode + "'>" + item.bankName + "</option >");
                        });
                    }
                    $("select[name='bankCode']").find("option[value=" + res.bankCode + "]").prop("selected", true);
                    $("#orderNo").html(res.orderNo);
                    $("#cardNumber").html(res.cardNumber);
                    $("#secCardNumber").html(res.secCardNumber);

                    FlashPay.Util.SetInputVal("bcid", res.bcid);
                    $("select[name='cardType']").find("option[value=" + res.cardType + "]").prop("selected", true);
                    FlashPay.Util.SetInputVal("transportRate", res.transportRate);
                    $("select[name='usingStatus']").find("option[value=" + res.usingStatus + "]").prop("selected", true);
                    $("select[name='enableStatus']").find("option[value=" + res.enableStatus + "]").prop("selected", true);
                    $("#loginName").html(res.loginName);
                    FlashPay.Util.SetInputVal("passwordLogin", res.passwordLogin);
                    FlashPay.Util.SetInputVal("passwordQuery", res.passwordQuery);
                    FlashPay.Util.SetInputVal("passwordPay", res.passwordPay);
                    FlashPay.Util.SetInputVal("passwordShield", res.passwordShield);
                    FlashPay.Util.SetInputVal("originalPassword", res.originalPassword);
                    $("select[name='usbType']").find("option[value=" + res.usbType + "]").prop("selected", true);
                    $("#documentNumber").html(res.documentNumber);
                    $("#accountBank").html(res.accountBank);
                    $("#phoneNumber").html(res.phoneNumber);
                    FlashPay.Util.SetInputVal("paymentStart", res.paymentStart);
                    FlashPay.Util.SetInputVal("paymentEnd", res.paymentEnd);
                    FlashPay.Util.SetInputVal("payFeeRatio", res.payFeeRatio);
                    $("select[name='crossBankPay']").find("option[value=" + res.crossBankPay + "]").prop("selected", true);
                    FlashPay.Util.SetInputVal("depositFeeRatio", res.depositFeeRatio);
                    $("#ipAddress").html(res.ipAddress);
                    FlashPay.Util.SetInputVal("aliPayCardIndex", res.aliPayCardIndex);
                    FlashPay.Util.SetInputVal("aliPayBankMark", res.aliPayBankMark);
                    FlashPay.Util.SetInputVal("aliPayCardName", res.aliPayCardName);
                    FlashPay.Util.SetInputVal("remark", res.remark);
                    if (res.cardType == 3) {
                        var depositTypeArray = res.depositType.split(',');
                        for (var i = 0; i < depositTypeArray.length; i++) {
                            $('input[name="deposit"][value="' + depositTypeArray[i] + '"]').prop('checked', true);
                        }
                    }
                    if (res.sysConfigResponse != null) {
                        $.each(res.sysConfigResponse, function (i, item) {
                            paymentType.append("<option value='" + item.configValue + "'>" + item.configContent + "</option >");
                        });
                        $("select[name='paymentType']").find("option[value=" + res.paymentType + "]").prop("selected", true);
                    }

                    //额外限制
                    if (res.bankCardExtraLimitResponse != null) {
                        //FlashPay.Util.SetInputVal("limitCloseDate", GetDateByTime(res.bankCardExtraLimitResponse.limitCloseDate));
                        //FlashPay.Util.SetInputVal("limitOpenDate", GetDateByTime(res.bankCardExtraLimitResponse.limitOpenDate));
                        //$("input[name='limitRepeat'][value='" + res.bankCardExtraLimitResponse.limitRepeat + "']").attr("checked", true);
                        FlashPay.Util.SetInputVal("limitDepositAmount", res.bankCardExtraLimitResponse.limitDepositAmount);
                        FlashPay.Util.SetInputVal("limitDepositCount", res.bankCardExtraLimitResponse.limitDepositCount);
                        //$("input[name='limitChangetoPay'][value='" + res.bankCardExtraLimitResponse.limitChangetoPay + "']").attr("checked", true);
                        FlashPay.Util.SetInputVal("limitPayAmount", res.bankCardExtraLimitResponse.limitPayAmount);
                        FlashPay.Util.SetInputVal("limitPayCount", res.bankCardExtraLimitResponse.limitPayCount);
                        //$("input[name='limitChangetoDeposit'][value='" + res.bankCardExtraLimitResponse.limitChangetoDeposit + "']").attr("checked", true);
                        $("input[name='limitStatus'][value='" + res.bankCardExtraLimitResponse.limitStatus + "']").attr("checked", true);
                    } else {
                        $("input[name='limitRepeat'][value='2']").attr("checked", true);
                        $("input[name='limitChangetoPay'][value='2']").attr("checked", true);
                        $("input[name='limitChangetoDeposit'][value='2']").attr("checked", true);
                        $("input[name='limitStatus'][value='2']").attr("checked", true);
                    }
                    //中转卡
                    if (res.bankInfoResponse != null) {
                        destinationBankCodes.append("<option value=''>请选择</option>");
                        $.each(res.bankInfoResponse, function (i, item) {
                            destinationBankCodes.append("<option value='" + item.bankCode + "'>" + item.bankName + "</option >");
                        });
                    }

                    //转入的中转卡
                    if (res.selectTransferCardResponse != null) {
                        var menuPermissionText = doT.template($("#addTpl").text());
                        $("table.transportCardRule tbody").html(menuPermissionText(res.selectTransferCardResponse));
                    } else {
                        var menuPermissionText = doT.template($("#addTpl").text());
                        $("table.transportCardRule tbody").html(menuPermissionText(null));
                    }

                    if (res.transportCardResponse != null) {

                        destinationBCID.empty();

                        destinationBCID.append("<option value=''>请选择</option>");
                        if (res.companyBankCardResponse != null) {
                            $.each(res.companyBankCardResponse, function (i, item) {
                                destinationBCID.append("<option value='" + item.bcId + "'>" + item.cardTypeName + " " + item.bankCode + " " + item.cardName + "</option >");
                            });
                        }
                        $("input[name='showedOnDepositCard'][value='" + res.transportCardResponse.showedOnDepositCard + "']").attr("checked", true);
                        FlashPay.Util.SetInputVal("triggeredAmount", res.transportCardResponse.triggeredAmount);
                        FlashPay.Util.SetInputVal("transferredAmount", res.transportCardResponse.transferredAmount);
                        FlashPay.Util.SetInputVal("preservedBalance", res.transportCardResponse.preservedBalance);
                        if (res.transportCardResponse.transportMethod == 1) {
                            $("input[name='transportMethod'][value='1']").attr("checked", true);
                            $(".destinationBCID").hide();
                            $(".destinationCardType,.destinationBankCode,.destinationOrderSideBalance").show();

                            if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationBCID)) {
                                let destinationBCIDArr = res.transportCardResponse.destinationBCID.split(",");
                                destinationBCID.val(destinationBCIDArr).trigger("change");
                            }

                            FlashPay.Util.SetInputVal("destinationOrderSideBalance", res.transportCardResponse.destinationOrderSideBalance);

                            if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationCardType)) {
                                let destinationCardTypeArr = res.transportCardResponse.destinationCardType.split(",");
                                destinationCardType.val(destinationCardTypeArr).trigger("change")
                            }

                            if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationBankCode)) {
                                let destinationBankCodeArr = res.transportCardResponse.destinationBankCode.split(",");
                                destinationBankCodes.val(destinationBankCodeArr).trigger("change")
                            }
                        } else {
                            $("input[name='transportMethod'][value='2']").attr("checked", true);
                            $(".destinationBCID").show();
                            $(".destinationCardType,.destinationOrderSideBalance,.destinationBankCode").hide();


                            let arr = res.transportCardResponse.destinationBCID.split(",");
                            destinationBCID.val(arr).trigger("change");

                            if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationBCID)) {
                                let destinationBCIDArr = res.transportCardResponse.destinationBCID.split(",");
                                destinationBCID.val(destinationBCIDArr).trigger("change");
                            }

                             FlashPay.Util.SetInputVal("destinationOrderSideBalance", res.transportCardResponse.destinationOrderSideBalance);

                            if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationCardType)) {
                                let destinationCardTypeArr = res.transportCardResponse.destinationCardType.split(",");
                                destinationCardType.val(destinationCardTypeArr).trigger("change")
                            }
                            if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationBankCode)) {
                                let destinationBankCodeArr = res.transportCardResponse.destinationBankCode.split(",");
                                destinationBankCodes.val(destinationBankCodeArr).trigger("change")
                                //$("select[name='destinationBankCode']").find("option[value=" + res.transportCardResponse.destinationBankCode + "]").prop("selected", true);
                            }
                        }
                        //if (!FlashPay.Util.isNullOrEmptySpance(res.selectTransferCardResponse)) {
                        //    $("input[name='transferMethod'][value='2']").attr("checked", true);

                        //    $(".destinationBCID").show();
                        //    $(".destinationCardType,.destinationOrderSideBalance,.destinationBankCode").hide();

                        //    let arr = res.transportCardResponse.destinationBCID.split(",");
                        //    destinationBCID.val(arr).trigger("change");

                        //    if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationBCID)) {
                        //        let destinationBCIDArr = res.transportCardResponse.destinationBCID.split(",");
                        //        destinationBCID.val(destinationBCIDArr).trigger("change");
                        //    }

                        //     FlashPay.Util.SetInputVal("destinationOrderSideBalance", res.transportCardResponse.destinationOrderSideBalance);

                        //    if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationCardType)) {
                        //        let destinationCardTypeArr = res.transportCardResponse.destinationCardType.split(",");
                        //        destinationCardType.val(destinationCardTypeArr).trigger("change")
                        //    }
                        //    if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationBankCode)) {
                        //        let destinationBankCodeArr = res.transportCardResponse.destinationBankCode.split(",");
                        //        destinationBankCodes.val(destinationBankCodeArr).trigger("change")
                        //        //$("select[name='destinationBankCode']").find("option[value=" + res.transportCardResponse.destinationBankCode + "]").prop("selected", true);
                        //    }
                        //}
                        //else {
                        //    $("input[name='transferMethod'][value='1']").attr("checked", true);

                        //    $(".destinationBCID").hide();
                        //    $(".destinationCardType,.destinationBankCode,.destinationOrderSideBalance").show();
                            

                        //    if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationBCID)) {
                        //        let destinationBCIDArr = res.transportCardResponse.destinationBCID.split(",");
                        //        destinationBCID.val(destinationBCIDArr).trigger("change");
                        //    }

                        //    FlashPay.Util.SetInputVal("destinationOrderSideBalance", res.transportCardResponse.destinationOrderSideBalance);

                        //    if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationCardType)) {
                        //        let destinationCardTypeArr = res.transportCardResponse.destinationCardType.split(",");
                        //        destinationCardType.val(destinationCardTypeArr).trigger("change")
                        //    }

                        //    if (!FlashPay.Util.isNullOrEmptySpance(res.transportCardResponse.destinationBankCode)) {
                        //        let destinationBankCodeArr = res.transportCardResponse.destinationBankCode.split(",");
                        //        destinationBankCodes.val(destinationBankCodeArr).trigger("change")
                        //        $//("select[name='destinationBankCode']").find("option[value=" + res.transportCardResponse.destinationBankCode + "]").prop("selected", true);
                        //    }
                        //}
                    }
                    else {
                        $("input[name='showedOnDepositCard'][value='2']").attr("checked", true);

                        FlashPay.Util.SetInputVal("triggeredAmount", 5000);
                        FlashPay.Util.SetInputVal("transferredAmount", 0);
                        FlashPay.Util.SetInputVal("preservedBalance", 25);

                        $("input[name='transferMethod'][value='1']").attr("checked", true);
                        FlashPay.Util.SetInputVal("destinationOrderSideBalance", 30000);

                        $(".destinationCardType,.destinationBankCodes").show();
                        $(".destinationBCID").hide();

                        destinationBCID.empty();
                        destinationBCID.append("<option value=''>请选择</option>");
                        if (res.companyBankCardResponse != null) {
                            $.each(res.companyBankCardResponse, function (i, item) {
                                destinationBCID.append("<option value='" + item.bcId + "'>" + item.cardTypeName + " " + item.bankCode + " " + item.cardName + "</option >");
                            });
                        }
                    }
                }
            });

            cover.Remove();
        }

        function xx(cardType) {
            if (cardType == 1) {
                $("select[name='companyId']").removeAttr("disabled")
                $(".depositFeeRatio").show();
                //额外限制
                $(".limit").show();

                $(".paymentStart,.paymentEnd,.payFeeRatio,.crossBankPay,.depositType,.paymentType,.transportRate,.apiTransport,.transportCard").hide();
                
            } else if (cardType == 2) {
                $("select[name='companyId']").removeAttr("disabled")
                //额外限制
                $(".paymentStart,.paymentEnd,.payFeeRatio,.crossBankPay,.depositType,.depositFeeRatio,.paymentType,.transportRate,.apiTransport,.transportCard").show();
            } else if (cardType == 3) {
                $("select[name='companyId']").removeAttr("disabled")
                //付款卡
                $(".paymentStart,.paymentEnd,.payFeeRatio,.crossBankPay,.depositType,.paymentType").show();
                //收款卡
                $(".transportRate,.apiTransport,.depositFeeRatio,.transportCard").hide();
            } else if (cardType == 4) {
                $("select[name='companyId']").attr("disabled", true);
                $("select[name='companyId']").find("option[value='0']").prop("selected", true);
                $(".transportRate,.apiTransport,limitBankCode").hide();
                //额外限制
                $(".limit").hide();
                //中转
                $(".transportCard").hide();
            }
        }

        //将时间截取成日期
        function GetDateByTime(time, type = 0) {
            if (time == null || time == "null" || time == undefined) return "";
            time = time.replace("T", " ").replace("1970-01-01 00:00:00", " ");
            if (type != 0) return time;
            return time.substr(0, 19);
        }

        function save() {

            var data = $("#form").serializeObject();

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            var depositType = new Array();
            $.each($('input[name="deposit"]:checkbox'), function () {
                if (this.checked) {
                    console.info($(this).val());
                }
            });

            depositType = [];

            $("input[name='deposit']:checked").each(function () {
                depositType.push($(this).val());
            });

            data.depositType = depositType.join(',');
            var transportCardRules = [];
            $("table.transportCardRule>tbody>tr").each(function (index) {
                var destinationBCID = $(this).find("input[name='destinationBCID']").val();
                var destinationBCIDAmountLimit = $(this).find("input[name='destinationBCIDAmountLimit']").val();
                var transportCardRule = {};
                transportCardRule.DestinationBCID = destinationBCID;
                transportCardRule.DestinationBCIDAmountLimit = destinationBCIDAmountLimit;
                transportCardRules.push(transportCardRule);
            });
            data.TransportCardRules = transportCardRules;

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Bank/BankEditOrAdd",
                data: data,
                success: function (response) {
                    if (response.success) {
                        cover.Remove();
                        FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    } else {
                        cover.Remove();
                        FlashPay.UI.Tip_short_warning("操作失败！" + response.errorMessage);
                    }
                },
                error: function (json) {
                    cover.Remove();
                    FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });
        }

        function cancel() {
            FlashPay.UI.CloseDialog();
        }

        function changeInputType(obj) {
            var that = $(obj).prev();
            if (that.attr('type') == 'text') {
                that.attr('type', 'password');
                $(obj).find("i").removeClass("glyphicon-eye-open");
                $(obj).find("i").addClass("glyphicon-eye-close");
            } else {
                that.attr('type', 'text');
                $(obj).find("i").removeClass("glyphicon-eye-close");
                $(obj).find("i").addClass("glyphicon-eye-open");
            }
        }

        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name] !== undefined) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };
    </script>
</body>
</html>